package com.zyg.manager.service.impl;

import org.springframework.stereotype.Service;

import java.security.Key;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zyg.common.utils.PageUtils;
import com.zyg.common.utils.Query;

import com.zyg.manager.dao.TypeTemplateDao;
import com.zyg.manager.entity.TypeTemplateEntity;
import com.zyg.manager.service.TypeTemplateService;


@Service("typeTemplateService")
public class TypeTemplateServiceImpl extends ServiceImpl<TypeTemplateDao, TypeTemplateEntity> implements TypeTemplateService {
    //分页带条件查询模板信息
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        //创建条件构造器对象
        QueryWrapper<TypeTemplateEntity> typeTemplateEntityQueryWrapper = new QueryWrapper<>();
        //获取key
        Object key = params.get("key");
        if(key != null){
            //添加条件
            typeTemplateEntityQueryWrapper.like("id", key)
                                          .or()
                                          .like("name",key);
        }
        //开始分页带条件查询
        IPage<TypeTemplateEntity> page = this.page(
                new Query<TypeTemplateEntity>().getPage(params),
                typeTemplateEntityQueryWrapper
        );

        return new PageUtils(page);
    }

}